package image;

import java.util.Random;

public final class RandomCodeUtils { 
	  
    /** 
     * 随机码范围 
     */ 
    private static char[] source = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', 
        '3', '4', '5', '6', '7', '8', '9'}; 
 
    /** 
     * 生成随机码 
     * @param length 随机码长度 
     * @return 随机码 
     * @since 0.2 
     */ 
    public static String random(int length) { 
        Random random = new Random(); 
        int sourceLength = source.length; 
        StringBuilder sb = new StringBuilder(length); 
        for (int i = 0; i < length; i++) { 
            sb.append(source[random.nextInt(sourceLength)]); 
        } 
        return sb.toString(); 
    } 
} 

